package cn.jbolt.ai.agent.controller;

import cn.jbolt.ai.agent.service.BaseKeysInfoService;
import cn.jbolt.ai.app.service.AiAppConfigService;
import cn.jbolt.util.Pager;
import cn.jbolt.util.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/base")
@Tag(name = "标书智能体控制类")
public class BaseController {

    @Autowired
    private BaseKeysInfoService baseKeysInfoService;


    @Operation(summary = "获取所有关键词信息",
            description = "trainType训练类型" )
    @GetMapping("/baseList")
    public Result listByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","企业测试1");
        map.put("compScale","大型");
        map.put("compAddr","江苏省苏州市姑苏区XX街道");
        map.put("compNetwork","http://www.leiji.com");
        map.put("compPhone","138XXXXXXXX");
        map.put("compCode","0516002");
        map.put("compTbAllCnt","500");
        map.put("compTbHighCnt","10");
        map.put("compTbMidCnt","100");
        map.put("compTbLowCnt","200");
        map.put("compTbWorkers","190");
        map.put("compFormDate","2025-01-01 -- 2099-12-31");
        map.put("compTbMangerCnt","10");
        listMap.add(map);
        map = new HashMap<>();
        map.put("compName","企业测试2");
        map.put("compScale","小型");
        map.put("compAddr","江苏省苏州市相城区XX街道");
        map.put("compNetwork","http://www.leiji.com");
        map.put("compPhone","138XXXXXXXX");
        map.put("compCode","0516002");
        map.put("compTbAllCnt","200");
        map.put("compTbHighCnt","5");
        map.put("compTbMidCnt","80");
        map.put("compTbLowCnt","20");
        map.put("compTbWorkers","95");
        map.put("compFormDate","2024-01-01 -- 2099-12-31");
        map.put("compTbMangerCnt","5");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }

    @Operation(summary = "获取所有招标公告",
            description = "trainType训练类型" )
    @GetMapping("/blList")
    public Result collecListByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","企业测试1");
        map.put("compTyxyCode","987234XXXXXXXX");
        map.put("compFrdb","张三");
        map.put("compAmt","1000万");
        map.put("compFlag","");
        map.put("compZcAddress","苏州市姑苏区XXX街道XXX");
        map.put("compCreateDate","2000-5-1");
        map.put("compDjDt","2025-01-01");
        map.put("compEmail","compXXX.163.com");
        map.put("compJyfw","");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }


    @Operation(summary = "获取所有订阅列表",
            description = "trainType训练类型" )
    @GetMapping("/openList")
    public Result subsListByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","企业测试1");
        map.put("compOpenAcctName","企业测试开户账号名称");
        map.put("compOpenAcctNo","XXXXXXXXXXXX");
        map.put("compOpenBank","招商银行（姑苏分区）");
        map.put("compOpenBankPhone","XXXXXXXX");
        map.put("compOpenBankAddress","苏州市姑苏区XXX街道XXX");
        map.put("compOpenBakFile","XXXX.dco");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }

    @Operation(summary = "获取所有标讯推荐",
            description = "trainType训练类型" )
    @GetMapping("/psersonList")
    public Result commandListByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","测试企业1");
        map.put("userName","张三");
        map.put("userDocId","3205XXXXXXXXX");
        map.put("userSex","男");
        map.put("userPhone","138XXXXXXX");
        map.put("userWorks","项目经理");
        map.put("isFr","否");
        map.put("userStatus","在职");
        map.put("userSb","XXX社保权益单.doc");
        map.put("userZhshu","XXX一级建筑师.doc");
        map.put("userZhshuStatus","有效");
        map.put("userLdht","HTXXXXXX");
        listMap.add(map);
        map = new HashMap<>();
        map.put("compName","测试企业1");
        map.put("userName","李四");
        map.put("userDocId","3201XXXXXXXXX");
        map.put("userSex","男");
        map.put("userPhone","158XXXXXXX");
        map.put("userWorks","总经理");
        map.put("isFr","是");
        map.put("userStatus","在职");
        map.put("userSb","XXX社保权益单.doc");
        map.put("userZhshu","XXX一级建筑师.doc");
        map.put("userZhshuStatus","有效");
        map.put("userLdht","HTXXXXXX");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }


    @Operation(summary = "获取所有标讯推荐",
            description = "trainType训练类型" )
    @GetMapping("/perfList")
    public Result perfListByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","测试企业1");
        map.put("compZhFlag","资质证书");
        map.put("fzhjg","国家住建局");
        map.put("zhbh","BHXXXXXXXX");
        map.put("yxq","长期");
        map.put("zhyxq","--");
        map.put("zhshFile","一级建筑师证书.doc");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }


    @Operation(summary = "获取所有标讯推荐",
            description = "trainType训练类型" )
    @GetMapping("/certList")
    public Result certListByPage(
            Integer page,Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","测试企业1");
        map.put("xmbh","BHXXXXXXXXXX");
        map.put("xmName","XXXX项目");
        map.put("htAmt","500万");
        map.put("jsdwName","苏州市雷捷有限公司");
        map.put("xmfzr","张三");
        map.put("jsfzr","李四");
        map.put("yjfl","");
        map.put("openDt","2020-01-01");
        map.put("endDt","2024-07-31");
        map.put("xmStatus","已竣工");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }


    @Operation(summary = "获取所有标讯推荐",
            description = "trainType训练类型" )
    @GetMapping("/finaList")
    public Result finaListByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords,
            @RequestParam(required = false) Long knowledgeBaseId,
            @RequestParam(required = false) String trainType,
            @RequestParam(required = false) Integer status) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("compName","测试企业1");
        map.put("finaTime","2025-03-02");
        map.put("finaType","");
        map.put("finaInfoName","XXX项目结算额");
        map.put("finaBak","");
        map.put("finaCreateDt","2025-05-07");
        map.put("finaFile","XXX结算单.doc，XXX确认书");
        listMap.add(map);
        List<List<Map<String, Object>>> resultList = new ArrayList<>();
        resultList.add(listMap);

        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
        pager.setRecords(listMap);

        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }


    @Operation(summary = "获取所有关键词内容")
    @GetMapping("/keysList")
    public Result keysListByPage(
            Integer page,
            Integer pageSize,
            @RequestParam(required = false) String keywords) {
        return baseKeysInfoService.listByPage(page,pageSize,keywords);

//        List<Map<String, Object>> listMap = new ArrayList<>();
//        Map<String,Object> map = new HashMap<>();
//        map.put("compName","测试企业1");
//        map.put("compScale","大型");
//        map.put("keysType","企业业绩");
//        map.put("keysBak","");
//        listMap.add(map);
//        map = new HashMap<>();
//        map.put("compName","测试企业2");
//        map.put("compScale","中型");
//        map.put("keysType","企业资质");
//        map.put("keysBak","");
//        listMap.add(map);
//        List<List<Map<String, Object>>> resultList = new ArrayList<>();
//        resultList.add(listMap);
//
//        Page<Map<String,Object>> pager = new Page<Map<String, Object>>();
//        pager.setRecords(listMap);
//
//        return Result.success(Pager.from(pager));//fileService.listByPage(page, pageSize, keywords, knowledgeBaseId, trainType, status);
    }
}
